﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using webapp4U.BOL;

namespace webapp4U.UI
{
    public partial class _Default : System.Web.UI.Page
    {
        int CateID = -1;

        protected void Page_Load(object sender, EventArgs e)
        {
            CateID = Globals.GetIntFromQueryString("CateID");

            Load_Title();

            Pager.IndexChanged += new EventHandler(PageIndex_Changed);
            if (!Page.IsPostBack)
                this.DataBind();
        }

        private void PageIndex_Changed(Object sender, EventArgs e)
        {
            DataBind();
        }


        private void Load_Title()
        {
            if (CateID > 0)
            {
                PhotoCategory cate = PhotoCategory.GetCateByCateID(CateID);
                Title.TitleName = Globals.GetLang(cate.CateName, cate.CateName_en);
            }
        }


        public override void DataBind()
        {
            // hien thi bao nhieu hinh tren 1 trang
            Pager.PageSize = 27;

            List<webapp4U.BOL.File> obj = webapp4U.BOL.File.GetFileByCateID_Paging(CateID, Pager.PageIndex, Pager.PageSize);
            ItemsDataList.DataSource = obj;
            ItemsDataList.DataBind();

            Pager.TotalRecords = webapp4U.BOL.File.GetFileCountByCateID(CateID);
        }
       
    }
}